package com.zyw.security.shiro.web.authc.tk;

/**
 * 企业微信扫码登陆
 *
 * @author zhangyw
 * @date 2018/1/24 11:22
 */
public class WeixinQYAuthcToken extends BasicAuthcToken {

    private String code; // 用户允许授权后，微信回调带此参数

    /**
     * 用于保持请求和回调的状态，授权请求后原样带回给企业。
     * 该参数可用于防止csrf攻击（跨站请求伪造攻击），建议企业带上该参数，
     * 可设置为简单的随机数加session进行校验
     * 非必填
     */
    private String state;

    private String userid;

    public WeixinQYAuthcToken() {
    }

    public WeixinQYAuthcToken(String code) {
        this(code, null);
    }

    public WeixinQYAuthcToken(String code, String state) {
        this(code, state, null);
    }

    public WeixinQYAuthcToken(String code, String state, String host) {
        this.code = code;
        this.state = state;
        this.setHost(host);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    @Override
    public Object getPrincipal() {
        return getCode();
    }

    @Override
    public Object getCredentials() {
        return getState();
    }


}
